//
function login(username:string):string{
    return "as"
}

function login1<A>(username:A):A{
    return username
}

function login2<B,C>(b:B,c:C):[B,C]{
    return [b,c]
}

let res=login("")
console.log(res)
let res1=login1(666)
console.log(res1)
let res2=login2("age",18)
console.log(res2)
//约束
function aaa<T extends string>(a:T):T{
    return a
}

type bbb=string|number
function aaa1<T extends bbb>(a:T){
    return a
}

type bbb1="a"|"b"
function aaa2<T extends bbb1>(a:T){
    return a
}
let res3=aaa("sdjk")
let res4=aaa1(47)
let res5=aaa2("a")

type ccc={name:string,age:number}
let p:ccc={
    name:"zs",
    age:18
} 

type ccc1=keyof ccc
function ccc2<T extends ccc1>(a:T){
    return a
}
let res6=ccc2("age")
console.log(res6)

function ddd(obj,xxx){
    return obj[xxx]
}
let res7=ddd({name:"ls",age:19},"age")
console.log(res7)

function ddd1(obj:{name:string,age:number},xxx:string){
    return obj[xxx]
}
let res8=ddd1({name:"ls",age:19},"ageg")
console.log(res8)

function ddd2<T,K extends keyof T>(obj:T,xxx:K){
    return obj[xxx]
}
let res9=ddd2("fhj","substring")
console.log(res9)

let o={
    height:180,
    xxx:()=>{
        console.log("666")
        return "ok"
    }
}
console.log(o.xxx())
